package com.groupnections.server.database.liveFeed;

import java.util.Arrays;
import java.util.List;

import com.googlecode.objectify.Objectify;
import com.groupnections.server.database.ObjectifyServiceCreation;
import com.groupnections.shared.Entity;
import com.groupnections.shared.LiveFeed;

public class ListLiveFeeds {

	public static LiveFeed[] list(Entity entity) {

		Objectify objfyService = ObjectifyServiceCreation.gerService();

		List<LiveFeed> liveFeedListFrom = objfyService.query(LiveFeed.class)
				.filter("entityFrom", entity).order("liveFeedDate").list();

		List<LiveFeed> liveFeedListTo = objfyService.query(LiveFeed.class)
				.filter("entityTo", entity).order("liveFeedDate").list();

		liveFeedListFrom.addAll(liveFeedListTo);

		LiveFeed[] liveFeedArray = new LiveFeed[liveFeedListFrom.size()];

		liveFeedListFrom.toArray(liveFeedArray);

		Arrays.sort(liveFeedArray);

		return liveFeedArray;
	}

	// SaveLiveFeed
	// .addNew(SaveLiveFeed
	// .loadLiveFeed(
	// "LiveSource",
	// "AllineO",
	// "@AllineO created a new To Do class: SaveFeatureFile in the project @LiveSource"));

	// SaveLiveFeed
	// .addNew(SaveLiveFeed
	// .loadLiveFeed(
	// "LiveSource",
	// "AaronVonderHaar",
	// "@AaronVonderHaar created a new To Do class: ListFeatureFiles in the project @LiveSource"));

}